 Map<String, Object> params = new HashMap<>();

//        String existsSql = " AND EXISTS (" + "SELECT 1 FROM EHUB_INVITATION_DETAIL D WHERE D.APPLY_ID = APPLY.ID AND D.STATUS != 'DELETED' ";
//        existsSql += " AND D.STATUS = :existsPersonStatus ";
//        existsSql += ")";

        String querySql = EhubSqlBuilder
                // 开始拼接初始SQL
                .startSqlAppend(InvitationApplyVo.QUERY_SQL, params)
                // 后端直接拼SQL 放在前面
                .appendIfTrue(userService.isEnterprise(), " and apply.USC_CODE = '" + userService.getUscCode() + "' ")
                .append(this.buildInClause(dto.getInPassReasonStatus(), "APPLY.PASS_REASON_STATUS"))
                .append(this.buildInClause(dto.getInActAuditStatusOne(), "APPLY.ACT_AUDIT_STATUS_ONE"))
                .append(this.buildInClause(dto.getInActAuditStatusTwo(), "APPLY.ACT_AUDIT_STATUS_TWO"))
                .append(" AND APPLY.APPLY_TYPE != '" + CommonConstant.applyType.INVITATION_PROLONG + "' ")
                .append(" AND APPLY.APPLY_TYPE != '" + CommonConstant.applyType.INVITATION_PROLONG_INDIVIDUAL + "' ")
                .append(" AND APPLY.APPLY_TYPE != '" + CommonConstant.applyType.INVITATION_IND_APPLY + "' ")
                .append(generateExistsSql(dto))// 直接拼SQL的,不用放map,但是dto中相关字段需要加注解防止SQL注入
                // 前端传参采用map,防止SQL注入 注意map中的条件会拼接到SQL最后
                .putConditions(dto.getApplyNumber(), "like_apply_applyNumber")
                .putConditions(dto.getApplyType(), "eq_apply_applyType")
                .putConditions(dto.getEmergencyType(), "eq_apply_emergencyType")
                .putConditions(dto.getPassReasonStatus(), "eq_apply_passReasonStatus")
                .putConditions(dto.getActAuditStatusOne(), "eq_apply_auditStatusOne")
                .putConditions(dto.getActAuditStatusTwo(), "eq_apply_auditStatusTwo")
                .putConditions(dto.getStatus(), "eq_apply_status")
                .putConditions(dto.getActType(), "eq_apply_actType")
                .putConditions(dto.getOrgName(), "like_apply_orgName")
                .putConditions(dto.getUscCode(), "eq_apply_uscCode")
                .putConditions(dto.getCreateBy(), "eq_apply_createBy")
                .putConditions(dto.getDeclTimeStart(), "ge_apply_declTimeStart")
                .putConditions(dto.getDeclTimeEnd(), "le_apply_declTimeEnd")
                .putConditions(dto.getActId(), "eq_apply_actId")
                .putConditions(dto.getActName(), "like_act_actName")
//                .putMap("orderBy", "apply_updateTime,desc")
                .putMap("orderBy", "APPLY.UPDATE_TIME,desc")
                .putMap("orderBy", "DETAIL.UPDATE_TIME,desc")
//                .putMap("orderSql", "APPLY.UPDATE_TIME DESC")// 写法2
                .getSql();

        List<Query> sqlQueryList = createSqlQueryList(querySql, params);
        NativeQueryImpl query = sqlQueryList.get(1).unwrap(NativeQueryImpl.class);

//        // SQL中采用 DETAIL.STATUS = :existsPersonStatus   可采用此方法进行占位预编译,能与map混用(map底层也转为了占位的形式),但无法分页,需要SQL中手动分页
//        dto.setPersonStatus(InvitationConstant.detailStatus.pass);
//        query.setParameter("existsPersonStatus", dto.getPersonStatus());
//        List<Map<String,Object>> resultList = query.getResultList();
//        System.out.println("resultList.size() = " + resultList.size());

        InvitationApplyVo.addScalar(query).setResultTransformer(Transformers.ALIAS_TO_ENTITY_MAP);
        Page page = invitationDetailDomainService.queryPageByQuery(sqlQueryList, dto.getOffset(), dto.getLimit());

//        System.out.println("page.getCount() = " + page.getCount());
        return RestMultiResult.T(page.getResult(), page.getCount());























        Map<String, Object> params = new HashMap<>();

        String existsSql = " AND EXISTS (" + "SELECT 1 FROM EHUB_INVITATION_DETAIL D WHERE D.APPLY_ID = APPLY.ID AND D.STATUS != 'DELETED' ";
        existsSql += " AND D.STATUS = :existsPersonStatus ";
        existsSql += ")";

        String querySql = EhubSqlBuilder
                // 开始拼接初始SQL
                .startSqlAppend(InvitationApplyVo.QUERY_SQL, params)
                // 后端直接拼SQL 放在前面
                .appendIfTrue(userService.isEnterprise(), " and apply.USC_CODE = '" + userService.getUscCode() + "' ")
                .append(this.buildInClause(dto.getInPassReasonStatus(), "APPLY.PASS_REASON_STATUS"))
                .append(this.buildInClause(dto.getInActAuditStatusOne(), "APPLY.ACT_AUDIT_STATUS_ONE"))
                .append(this.buildInClause(dto.getInActAuditStatusTwo(), "APPLY.ACT_AUDIT_STATUS_TWO"))
                .append(" AND APPLY.APPLY_TYPE != '" + CommonConstant.applyType.INVITATION_PROLONG + "' ")
                .append(" AND APPLY.APPLY_TYPE != '" + CommonConstant.applyType.INVITATION_PROLONG_INDIVIDUAL + "' ")
                .append(" AND APPLY.APPLY_TYPE != '" + CommonConstant.applyType.INVITATION_IND_APPLY + "' ")
                .append(existsSql)
                .appendIfNotEmpty(dto.getDeclTimeStart(), " AND APPLY.DECL_TIME >= TO_DATE('" + dto.getDeclTimeStart() + "', 'YYYY-MM-DD HH24:MI:SS')")
                .appendIfNotEmpty(dto.getDeclTimeEnd(), " AND APPLY.DECL_TIME <= TO_DATE('" + dto.getDeclTimeEnd() + "', 'YYYY-MM-DD HH24:MI:SS')")
                // 前端传参采用map,防止SQL注入 注意map中的条件会拼接到SQL最后
                .putConditions(dto.getApplyNumber(), "like_apply_applyNumber")
                .putConditions(dto.getApplyType(), "eq_apply_applyType")
                .putConditions(dto.getEmergencyType(), "eq_apply_emergencyType")
                .putConditions(dto.getPassReasonStatus(), "eq_apply_passReasonStatus")
                .putConditions(dto.getActAuditStatusOne(), "eq_apply_auditStatusOne")
                .putConditions(dto.getActAuditStatusTwo(), "eq_apply_auditStatusTwo")
                .putConditions(dto.getStatus(), "eq_apply_status")
                .putConditions(dto.getActType(), "eq_apply_actType")
                .putConditions(dto.getOrgName(), "like_apply_orgName")
                .putConditions(dto.getUscCode(), "eq_apply_uscCode")
                .putConditions(dto.getCreateBy(), "eq_apply_createBy")
                .putConditions(dto.getActId(), "eq_apply_actId")
                .putConditions(dto.getActName(), "like_act_actName")
                .putMap("orderBy", "APPLY.UPDATE_TIME,desc")
                .getSql();

        List<Query> sqlQueryList = createSqlQueryList(querySql, params);
        NativeQueryImpl query = sqlQueryList.get(1).unwrap(NativeQueryImpl.class);

        // SQL中采用 DETAIL.STATUS = :existsPersonStatus   可采用此方法进行占位预编译,能与map混用(map底层也转为了占位的形式),但无法分页,需要SQL中手动分页
        dto.setPersonStatus(InvitationConstant.detailStatus.pass);
        query.setParameter("existsPersonStatus", dto.getPersonStatus());
        List<Map<String,Object>> resultList = query.getResultList();
        System.out.println("resultList.size() = " + resultList.size());